home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 072 (1988-11-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 072 (1988-11-15)(Ossowski, Stefan)(DE)(PD).adf / Globe / gdemo.c < prev    next >
C/C++ Source or Header  |  1988-08-14  |  16KB  |  685 lines

  1. /******************************************************************************
  2. *
  3. *    GlobeDemo.c v1.0 6/20/88  COPYRIGHT 1988 BOB CORWIN JR.
  4. *
  5. *    Inspired by "FRAMEDEMO" demo written by Sun Microsystems(TM)
  6. *    for their UNIX-based workstations.
  7. *
  8. *    Very simple frame animator. Looks for image 
  9. *    files in dir "GLOBEIMAGES:" with names "Fxx" Where xx 
  10. *    is a number from 01 to 30 representing RAW IMAGE BIT
  11. *    PLANE data dimensioned 128x64x2. If dir not found attemps to load
  12. *    from current directory. Works under amigaDOS and workbench.
  13. *    And icon is provided for workbench use.
  14. *
  15. *    Uses Mouse-Relative 'Pop-Up' menus code written by DEREK ZAHN 
  16. *    (Gambit Software, Madison WI), July 1987 ("DEREK, I REALLY LIKE
  17. *    YOUR POPUP MENUS,  THEY'RE SO EASY TO USE!")
  18. *
  19. *    This version functions in both High & Medium Resolution modes;
  20. *    however, the globeframes were designed for use in 
  21. *    medium resolution displays (640x200).
  22. *
  23. *    MAY BE FREELY DISTRIBUTED PROVIDED THIS HEADER IS INCLUDED.
  24. *    THIS IS FREEWARE HOWEVER, IF YOU USE IT LET ME KNOW WHAT YOU
  25. *    THINK OF IT.
  26. *
  27. *    BOB CORWIN             USENET: kodak!bc@ektools
  28. *    3 MELONIE DRIVE
  29. *    BROCKPORT, NEW YORK 14420
  30. *    (716)638-6361
  31. *                                    
  32. ******************************************************************************/
  33.  
  34. #include <exec/types.h>
  35. #include <exec/memory.h>
  36. #include <libraries/dos.h>
  37. #include <libraries/dosextens.h>
  38. #include <intuition/intuitionbase.h>
  39. #include <intuition/intuition.h>
  40. #include <graphics/gfxmacros.h>
  41. #include "popmenu.h"            /** HEADER FOR RELATIVE MENUS **/
  42.  
  43. extern LONG PopChoose();        /** RELATIVE MENUS 'MAIN' FUNCTION **/
  44. typedef struct Window WINDOW;
  45. typedef struct FileLock *LOCK;
  46.  
  47. struct GfxBase *GfxBase;
  48. struct IntuitionBase *IntuitionBase;
  49.  
  50. #define FRAMES 30
  51.  
  52. #define FASTER  0
  53. #define SLOWER  1
  54. #define COLORS  2
  55. #define ABOUT   3
  56. #define QUIT    4
  57.  
  58.                     /** FILE NAMES FOR IMAGES **/
  59. UBYTE FileNames[30][4] = { "f01","f02","f03","f04","f05","f06","f07","f08",
  60.         "f09","f10","f11","f12","f13","f14","f15","f16","f17","f18",
  61.         "f19","f20","f21","f22","f23","f24","f25","f26","f27","f28",
  62.         "f29","f30" };
  63.  
  64. struct NewWindow newwindow = {         /** DEMO'S WINDOW      **/
  65.     100,100,
  66.     138,80,
  67.     -1,-1,
  68.     MOUSEBUTTONS,            /** RMBTRAP FOR POPUP MENU USE **/
  69.     WINDOWDRAG|SIMPLE_REFRESH|ACTIVATE|NOCAREREFRESH|RMBTRAP ,
  70.     NULL,
  71.     NULL,
  72.     "Globe Demo",
  73.     NULL,
  74.     NULL,
  75.     NULL,NULL,NULL,NULL,
  76.     WBENCHSCREEN 
  77. };
  78. struct NewWindow about_window = {     /** WINDOW FOR DEMO'S INFO REQUESTER **/
  79.     12,22,
  80.     356,78,
  81.     -1,-1,
  82.     REQCLEAR,
  83.     SIMPLE_REFRESH|NOCAREREFRESH|RMBTRAP,
  84.     NULL,
  85.     NULL,
  86.     NULL,
  87.     NULL,
  88.     NULL,
  89.     NULL,NULL,NULL,NULL,
  90.     WBENCHSCREEN 
  91. };
  92.  
  93. WINDOW *GlobeWindow, *ReqWindow;
  94.  
  95. struct Gadget about_gadget = {         /** GADGET STRUCTURE FOR INFO REQUESTER **/
  96.     NULL,
  97.     4,2,340,70,
  98.     GADGHCOMP,
  99.     GADGIMMEDIATE|RELVERIFY|ENDGADGET,
  100.     REQGADGET|BOOLGADGET,
  101.     NULL,
  102.     NULL,    
  103.     NULL,
  104.     NULL, NULL, NULL, NULL
  105. };
  106. struct IntuiText about_text4 = {     /** TEXT STRUCTURE FOR INFO REQUESTER **/
  107.     (UBYTE) 0, (UBYTE) 1,
  108.     JAM1,
  109.     (SHORT) 10, (SHORT) 52,
  110.     NULL,
  111.     (UBYTE *) "POPUP Menus support by DEREK ZAHN ",
  112.     NULL
  113. };
  114. struct IntuiText about_text3 = {
  115.     (UBYTE) 0, (UBYTE) 1,
  116.     JAM1,
  117.     (SHORT) 10, (SHORT) 42,
  118.     NULL,
  119.     (UBYTE *) "by Sun Microsystems.",
  120.     &about_text4
  121. };
  122. struct IntuiText about_text2 = {
  123.     (UBYTE) 0, (UBYTE) 1,
  124.     JAM1,
  125.     (SHORT) 10, (SHORT) 32,
  126.     NULL,
  127.     (UBYTE *) "Inspired by demo 'Framedemo' ",
  128.     &about_text3
  129. };
  130. struct IntuiText about_text1 = {
  131.     (UBYTE) 1, (UBYTE) 0,
  132.     JAM2,
  133.     (SHORT) 10, (SHORT) 12,
  134.     NULL,
  135.     (UBYTE *) " GLOBE DEMO copyright 1988 by BOB CORWIN ",
  136.     &about_text2
  137. };
  138.  
  139. struct Requester about_request = {
  140.     NULL,
  141.     4,2,348,74,
  142.     0,0,
  143.     (struct Gadget *)&about_gadget,
  144.     NULL, /* about_border */
  145.     &about_text1,
  146.     NULL,    /* FLAGS */
  147.     2,    /* BACKFILL */
  148.     NULL,
  149.     { NULL },
  150.     NULL,
  151.     NULL,
  152.     { NULL }
  153.  
  154. };
  155.  
  156. struct IntuiText globe_text5_text = {    /** POP-UP MENU TEXT **/
  157.     (UBYTE) 0, (UBYTE) 1,
  158.     JAM1,
  159.     (SHORT) 10, (SHORT) 2,
  160.     NULL,
  161.     (UBYTE *) "Quit",
  162.     NULL
  163. };
  164.  
  165. struct MenuItem globe_text5 = {
  166.     NULL,
  167.     (SHORT) 0, (SHORT) 40,
  168.     (SHORT) 80, (SHORT) 10,
  169.     (USHORT) (ITEMTEXT | HIGHCOMP | ITEMENABLED),
  170.     (LONG) 0,
  171.     (APTR) &globe_text5_text,
  172.     NULL,
  173.     (BYTE) 0,
  174.     NULL,
  175.     (USHORT) 0
  176. };
  177.  
  178.  
  179. struct IntuiText globe_text4_text = {
  180.     (UBYTE) 0, (UBYTE) 1,
  181.     JAM1,
  182.     (SHORT) 10, (SHORT) 2,
  183.     NULL,
  184.     (UBYTE *) "About...",
  185.     NULL
  186. };
  187.  
  188. struct MenuItem globe_text4 = {
  189.     &globe_text5,
  190.     (SHORT) 0, (SHORT) 30,
  191.     (SHORT) 80, (SHORT) 10,
  192.     (USHORT) (ITEMTEXT | HIGHCOMP | ITEMENABLED),
  193.     (LONG) 0,
  194.     (APTR) &globe_text4_text,
  195.     NULL,
  196.     (BYTE) 0,
  197.     NULL,
  198.     (USHORT) 0
  199. };
  200.  
  201. struct IntuiText globe_text3_text = {
  202.     (UBYTE) 0, (UBYTE) 1,
  203.     JAM1,
  204.     (SHORT) 10, (SHORT) 2,
  205.     NULL,
  206.     (UBYTE *) "COLORS",
  207.     NULL
  208. };
  209.  
  210. struct MenuItem globe_text3 = {
  211.     &globe_text4,
  212.     (SHORT) 0, (SHORT) 20,
  213.     (SHORT) 80, (SHORT) 10,
  214.     (USHORT) (ITEMTEXT | HIGHCOMP | ITEMENABLED),
  215.     (LONG) 0,
  216.     (APTR) &globe_text3_text,
  217.     NULL,
  218.     (BYTE) 0,
  219.     NULL,
  220.     (USHORT) 0
  221. };
  222.  
  223. struct IntuiText globe_text2_text = {
  224.     (UBYTE) 0, (UBYTE) 1,
  225.     JAM1,
  226.     (SHORT) 10, (SHORT) 2,
  227.     NULL,
  228.     (UBYTE *) "SLOWER",
  229.     NULL
  230. };
  231.  
  232. struct MenuItem globe_text2 = {
  233.     &globe_text3,
  234.     (SHORT) 0, (SHORT) 10,
  235.     (SHORT) 80, (SHORT) 10,
  236.     (USHORT) (ITEMTEXT | HIGHCOMP | ITEMENABLED),
  237.     (LONG) 0,
  238.     (APTR) &globe_text2_text,
  239.     NULL,
  240.     (BYTE) 0,
  241.     NULL,
  242.     (USHORT) 0
  243. };
  244.  
  245. struct IntuiText globe_text1_text = {
  246.     (UBYTE) 0, (UBYTE) 1,
  247.     JAM1,
  248.     (SHORT) 10, (SHORT) 2,
  249.     NULL,
  250.     (UBYTE *) "FASTER",
  251.     NULL
  252. };
  253.  
  254. struct MenuItem globe_text1 = {
  255.     &globe_text2,
  256.     (SHORT) 0, (SHORT) 0,
  257.     (SHORT) 80, (SHORT) 10,
  258.     (USHORT) (ITEMTEXT | HIGHCOMP | ITEMENABLED),
  259.     (LONG) 0,
  260.     (APTR) &globe_text1_text,
  261.     NULL,
  262.     (BYTE) 0,
  263.     NULL,
  264.     (USHORT) 0
  265. };
  266.  
  267. struct Menu globe_menu = {
  268.     NULL,
  269.     (SHORT) -1 * ((50 + POPTITLEHEIGHT) / 2),
  270.     (SHORT) -1 * POPTITLEHEIGHT / 2,
  271.     (SHORT) 80, (SHORT) 50 + POPTITLEHEIGHT,
  272.     (USHORT) (MENUENABLED | POPTIDY | POPPOINTREL | POPRIGHTBUTTON | 
  273.           POPREMEMBER | POPTRIGGERUP),
  274.     (BYTE *) "Goodies",
  275.     &globe_text1
  276. };
  277.  
  278.                     /** ALTERNATE COLORS FOR GLOBE **/
  279.  
  280. UWORD colortab2[5][3] = { 4, 4, 15, 4, 4, 15,  4, 4, 15, 15, 14, 0, };
  281. UWORD colortab3[5][3] = { 0, 9,  5, 0, 0,  0, 13, 0,  5,  0,  7, 0, };
  282.  
  283.  
  284.  
  285. LOCK launchDir, imageDir;
  286.  
  287. struct RastPort *rastPort;
  288.  
  289. struct MsgPort *GlobePort;
  290.  
  291. struct GlobeMsg {
  292.     struct Message Msg;
  293.     UBYTE *images[FRAMES];    /** POINTERS TO IMAGE DATA FOR ALL INSTANCES **/
  294.     UWORD color_2R;        /** OF THIS PROGRAM TO SHARE.             **/
  295.     UWORD color_2G;
  296.     UWORD color_2B;
  297.     UWORD color_3R;
  298.     UWORD color_3G;
  299.     UWORD color_3B;
  300.     } globeMsg;    
  301.  
  302.  
  303. struct BitMap bitmap[FRAMES];
  304.  
  305. /*******************************************************************************
  306. *
  307. * InitGlobePort() 
  308. *
  309. *    This function initializes a MsgPort for all instances of this porgram
  310. *   to share. When 2nd and subsequent invocations of this program call this
  311. *   function, previous invocations are searched out and if found provide 
  312. *   pointers to the globedemo image data and also original the WorkBench colors,
  313. *   #2 & #3 which are to be restored on exit of the last copy of the program.
  314. *
  315. *******************************************************************************/
  316.  
  317. BOOL InitGlobePort() {
  318. UWORD t;
  319. BOOL found_port;
  320. struct GlobeMsg *gmsg;
  321.  
  322.   if(( GlobePort = (struct MsgPort *)FindPort("GlobeMR.Niwroc")) != 0) {
  323.     found_port = TRUE;
  324.  
  325.     Forbid();
  326.     gmsg = (struct GlobeMsg *)GlobePort->mp_MsgList.lh_Head;
  327.     for(t=0; t < FRAMES; t++)
  328.       globeMsg.images[t] = gmsg->images[t];    
  329.       globeMsg.color_2R = gmsg->color_2R;
  330.       globeMsg.color_2G = gmsg->color_2G;
  331.       globeMsg.color_2B = gmsg->color_2B;
  332.       globeMsg.color_3R = gmsg->color_3R;
  333.       globeMsg.color_3G = gmsg->color_3G;
  334.       globeMsg.color_3B = gmsg->color_3B;
  335.     Permit();
  336.  
  337.   }
  338.   else found_port = FALSE;
  339.  
  340.   GlobePort = (struct MsgPort *)CreatePort("GlobeMR.Niwroc",0); 
  341.  
  342.   return(found_port);
  343.      
  344. }
  345.  
  346. /*******************************************************************************
  347. *
  348. * SamaritanCleanUp(gp) 
  349. *
  350. *    This function searches for a resident port indicating a continuing need
  351. * for access to the GlobeDemo Image data. It returns either 30 or 0, indicating 
  352. * the number of image frames to deallocate.
  353. *
  354. *******************************************************************************/
  355.  
  356. UWORD SamaritanCleanUp(gp) struct MsgPort *gp; {
  357. struct MsgPort *gport;
  358. UWORD frames2free;
  359.  
  360.  
  361.    if(((gport = (struct MsgPort *)FindPort("GlobeMR.Niwroc")) != 0) && 
  362.     gport != gp) frames2free = 0;
  363.     
  364.    else
  365.         if((gport = (struct MsgPort *)FindName(gport,"GlobeMR.Niwroc")) != 0)
  366.         frames2free = 0;
  367.  
  368.    else frames2free = FRAMES;
  369.  
  370.    DeletePort(gp);
  371.    return(frames2free);
  372.  
  373. }
  374.  
  375.  
  376. /*******************************************************************************
  377. *
  378. * AllocBitMap(bm), FreeBitMap(bm), LoadBitMap(file,bm,colors)
  379. *
  380. * These Routines were borrowed from EA/COMMODORE IFF FILES & cropped for use
  381. * in this program.
  382. *
  383. *******************************************************************************/
  384.  
  385. UBYTE *AllocBitMap(bm) struct BitMap *bm; {
  386.     int i;
  387.     LONG psz = bm->BytesPerRow*bm->Rows;
  388.     UBYTE *ptr, *p = (UBYTE *)AllocMem(bm->Depth*psz, MEMF_CHIP|MEMF_PUBLIC);
  389.     ptr = p;
  390.     for (i=0; i<bm->Depth; i++)  { 
  391.     bm->Planes[i] = p;
  392.     p += psz;
  393.     }
  394.     return(ptr);
  395.  
  396.     }
  397.  
  398. void FreeBitMap(bm) struct BitMap *bm;  {
  399.  
  400.     if (bm->Planes[0])  {
  401.     FreeMem(bm->Planes[0], bm->BytesPerRow * bm->Rows * bm->Depth);
  402.     }
  403.     }
  404.  
  405. VOID LoadBitMap(file,bm,colors)    /*** LOAD IMAGE FILE INTO BITMAP ***/
  406.     LONG file;    
  407.     struct BitMap *bm;
  408.     SHORT *colors;
  409.     {
  410.     SHORT i;
  411.     LONG number, plane_size;
  412.     plane_size = bm->BytesPerRow*bm->Rows;
  413.     for (i=0; i<bm->Depth; i++) {
  414.     number =  Read(file, bm->Planes[i], plane_size);
  415.     if (number<plane_size) BltClear(bm->Planes[i],plane_size,1);
  416.     }
  417.  
  418.     }
  419.  
  420.  
  421.  
  422. /** main() ******************************************************************/
  423.  
  424.     
  425. void main()  
  426. {
  427.     struct IntuiMessage *message, *reqmsg;
  428.     ULONG class;
  429.     UWORD code;
  430.     WORD  gwidth,gheight,gdepth;        /** IMAGE DIMENSIONS **/
  431.     LONG  file, loop, frame, delay, t, val;
  432.     struct ViewPort *viewport;
  433.     struct ColorMap *colormap;
  434.     UWORD color2, color3, c;            /** USERS DEFAULT COLORS **/
  435.     UWORD color2R, color2G, color2B, color3R, color3G, color3B;
  436.     BOOL  resident;                /** TRUE IF ANOTHER INSTANCE **/
  437.                         /** OF PROGRAM IS RUNNING    **/
  438.  
  439.     if( !(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0)) ){
  440.     exit(0);
  441.     }
  442.  
  443.     if( !(IntuitionBase = (struct IntuitionBase *)
  444.       OpenLibrary("intuition.library",0)) ) {
  445.           goto jail1;
  446.     }
  447.  
  448.     delay  = 4;        /** DEFAULT INTERVAL BETWEEN GLOBEFRAMES **/
  449.  
  450.     gwidth  = 128;    /** GLOBE DIMENSIONS **/
  451.     gheight = 64;
  452.     gdepth  = 2;
  453.  
  454.     /********** LOOK FOR FOR EXISTING PORT & CREATE NEW PORT ************
  455.     *                                    *
  456.     * First look for the existance of another port. If one exists, use  *
  457.     * it's copy of image pointers. No need to load further copies of    *
  458.     * image data, initialize new BitMap only                *
  459.     *                                    *
  460.     *********************************************************************/
  461.  
  462.     if((resident = InitGlobePort()) == TRUE) {
  463.        for(loop = 0; loop < FRAMES; loop++) {
  464.        InitBitMap(&bitmap[loop], gdepth, gwidth, gheight);
  465.       bitmap[loop].Planes[0] = globeMsg.images[loop];
  466.       bitmap[loop].Planes[1] = globeMsg.images[loop]+1024;
  467.        }
  468.  
  469.     }
  470.     else {
  471.         /**********************************************************
  472.         *                              *
  473.         * Look for images in directory "GLOBEIMAGES". If no such  *
  474.         * directory exists look in current directory. If images   *
  475.         * still arn't found nothing to do but exit.          *
  476.         *                              *
  477.         **********************************************************/
  478.  
  479.     if((imageDir  = (LOCK)Lock("GLOBEIMAGES", ACCESS_READ)) != 0)
  480.        launchDir = (LOCK)CurrentDir(imageDir);
  481.     
  482.     for(loop = 0; loop < FRAMES; loop++) {
  483.     
  484.          file = Open(&FileNames[loop], MODE_OLDFILE);
  485.         if(!file) {
  486.         if(imageDir) {
  487.           for(t = 0; t < loop; t++) {
  488.             FreeBitMap(&bitmap[t]);        
  489.                   }
  490.  
  491.             } 
  492.         else {
  493.         }
  494.  
  495.           (VOID)SamaritanCleanUp(GlobePort);
  496.           goto jail3;
  497.  
  498.         }
  499.          InitBitMap(&bitmap[loop], gdepth, gwidth, gheight);
  500.         globeMsg.images[loop] = AllocBitMap(&bitmap[loop]);
  501.         LoadBitMap(file,&bitmap[loop], NULL);
  502.         Close(file);
  503.         }
  504.     }
  505.     
  506.  
  507.     if((GlobeWindow = (WINDOW *)OpenWindow(&newwindow)) == 0) {
  508.       goto jail4;
  509.     }
  510.  
  511.     viewport = (struct ViewPort *)ViewPortAddress(GlobeWindow);
  512.     rastPort = GlobeWindow->RPort;
  513.  
  514.     /*********************************************************************
  515.     *
  516.     *  Get & Save original colors for clean User-Friendly exit.
  517.     *
  518.     *********************************************************************/
  519.     if(!(resident)) {
  520.         colormap = viewport->ColorMap;
  521.  
  522.         color2  = GetRGB4(colormap, 2);
  523.         color2B = color2 & 15;
  524.         color2G = (color2 >> 4) & 15;
  525.         color2R = (color2 >> 8) & 15;
  526.  
  527.         color3  = GetRGB4(colormap, 3);
  528.         color3B = color3 & 15;
  529.         color3G = (color3 >> 4) & 15;
  530.         color3R = (color3 >> 8) & 15;
  531.  
  532.         globeMsg.color_2R = color2R;
  533.         globeMsg.color_2G = color2G;
  534.         globeMsg.color_2B = color2B;
  535.         globeMsg.color_3R = color3R;
  536.         globeMsg.color_3G = color3G;
  537.         globeMsg.color_3B = color3B;
  538.     }
  539.  
  540.     colortab2[4][0] = globeMsg.color_2R;
  541.     colortab2[4][1] = globeMsg.color_2G;
  542.     colortab2[4][2] = globeMsg.color_2B;
  543.     colortab3[4][0] = globeMsg.color_3R;
  544.     colortab3[4][1] = globeMsg.color_3G;
  545.     colortab3[4][2] = globeMsg.color_3B;
  546.  
  547.     PutMsg(GlobePort,(struct Message *)&globeMsg);
  548.  
  549.     c = 0;
  550.  
  551.     SetRGB4(viewport, 2, colortab2[0][0], colortab2[0][1], colortab2[0][2]);
  552.     SetRGB4(viewport, 3, colortab3[0][0], colortab3[0][1], colortab3[0][2]);
  553.     
  554.     /*********************************************************************
  555.     *
  556.     * Main Pop-Up Menu event loop - Normal Menu button events are trapped
  557.     * so Intuition just passes them on to us without acting on them. More
  558.     * information can be found in the POPMENU documentation.
  559.     *
  560.     *********************************************************************/
  561.  
  562.         while(1) {
  563.       for(frame = 0; frame < FRAMES; frame++) {
  564.  
  565.         while(message = (struct IntuiMessage *)
  566.         GetMsg(GlobeWindow->UserPort)) {
  567.             class = message->Class;
  568.             code = message->Code;
  569.             ReplyMsg(message);
  570.             switch(class) {
  571.               case MOUSEBUTTONS:
  572.                   switch(code) {
  573.  
  574.                   case MENUDOWN:
  575.                     val = (SHORT) PopChoose(&globe_menu,
  576.                       NULL);
  577.  
  578.                     switch(val) {
  579.                         case FASTER: if(delay > 7) 
  580.                                 delay -= 4;
  581.                             else    
  582.                             if(delay > 5) 
  583.                                 delay -= 2;
  584.                             else
  585.                             if(delay > 0)
  586.                                 delay--;
  587.                             break;
  588.  
  589.                         case SLOWER: if(delay < 4) 
  590.                                 delay++;
  591.                             else
  592.                             if(delay < 7)
  593.                                 delay += 2;
  594.                             else
  595.                                 delay += 4;
  596.                              break;
  597.  
  598. case COLORS: 
  599.    if(++c > 4) c = 0;
  600.    SetRGB4(viewport, 2, colortab2[c][0], colortab2[c][1], colortab2[c][2]);
  601.    SetRGB4(viewport, 3, colortab3[c][0], colortab3[c][1], colortab3[c][2]);
  602.  
  603.    break;
  604.  
  605.             case ABOUT: 
  606.                 if((ReqWindow = (WINDOW *)
  607.                 OpenWindow(&about_window)) != NULL) {
  608.  
  609.                 BltBitMapRastPort(&bitmap[frame],0,0,rastPort,
  610.                 5,12,128,64,0xc0);
  611.  
  612.                 (VOID)Request((struct Requester *)
  613.                         &about_request,    ReqWindow);
  614.  
  615.                 Wait(1<<ReqWindow->UserPort->mp_SigBit);
  616.                     reqmsg = (struct IntuiMessage *)
  617.                     GetMsg(ReqWindow->UserPort);
  618.  
  619.                     ReplyMsg(reqmsg);
  620.                     CloseWindow(ReqWindow); 
  621.                 }
  622.                 break;
  623.  
  624.             case QUIT: 
  625.                 goto jail5;                    
  626.                 default: break;
  627.                 }
  628.                 break;
  629.  
  630.               default: break;
  631.             }
  632.             break;
  633.  
  634.           default: break;
  635.         }
  636.  
  637.         }
  638.  
  639.         /** THIS IS THE WHOLE PROGRAM IN A SINGLE LINE **/
  640.         BltBitMapRastPort(&bitmap[frame],0,0,rastPort,5,12,128,64,0xc0);
  641.         Delay(delay);
  642.           }
  643.     }
  644.  
  645.  
  646.     /***************************************************************************
  647.     *
  648.     *  CLEAN UP CLEAN UP CLEAN UP CLEAN UP CLEAN UP CLEAN UP CLEAN UP CLEAN UP 
  649.     *
  650.     ***************************************************************************/
  651.  
  652.     jail5:
  653.     if(GlobeWindow) CloseWindow(GlobeWindow);
  654.  
  655.     jail4:
  656.  
  657.     /** LAST INSTANCE OF PROGRAM TO EXIT RETURNS MEMORY AND RESTORES COLORS **/
  658.  
  659.  
  660.     if((t = SamaritanCleanUp(GlobePort)) != 0) {
  661.            SetRGB4(viewport,2,colortab2[4][0],colortab2[4][1],colortab2[4][2]);
  662.            SetRGB4(viewport,3,colortab3[4][0],colortab3[4][1],colortab3[4][2]);
  663.     }
  664.  
  665.     while(t-- > 0) {
  666.       FreeBitMap(&bitmap[t]);
  667.     }
  668.  
  669.  
  670.     jail3:    
  671.     if(launchDir) (VOID)CurrentDir(launchDir);
  672.     if(imageDir) UnLock(imageDir);
  673.     
  674.     jail2:
  675.     if(IntuitionBase) CloseLibrary(IntuitionBase);
  676.  
  677.     jail1:
  678.     if(GfxBase) CloseLibrary(GfxBase);
  679.     exit(0);
  680.   }
  681.  
  682.  
  683.  
  684.  
  685.